</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户列表</title>
</head>
<body>
<?php
require_once('inc_admin.php');
//连接数据库
connect();
//编写 sql 语句
$sql = "select uid, uname, gender, birthdate, hobby, degree, intro, pic from users";
// 如果 用户 提交了表单，则获 取用户输入的 关键字
if($_POST['key']) {
$key = trim($_POST['key']);
$sql = $sql." where uname like '%{$key}%' ";
}
//echo $sql.'<br/>';
$result = mysql_query($sql) or die('查询失败！'.mysql_error());
?>
<center><h3>用户列表</h3></center>
<table align="center" width="80%">
172
<tr><td align="left" >
<form method=post action="">
请 输入用户名：
<input type="text" name="key">
<input type="submit" name='search' value=" 搜索">
</form>
</td></tr>
</table>
<table align="center" width="80%" border=1>
<tr>
<th>用户编号</th>
<th>用户名</th>
<th>性别</th>
<th>生日</th>
<th>爱好</th>
<th>学历</th>
<th>自我介绍</th>
<th width='80'>头像</th>
<th>操作</th>
</tr>
<?php
while($row = mysql_fetch_assoc($result)){
echo '<tr>';
echo '<td>'.$row['uid'].'</td>';
echo '<td>'.$row['uname'].'</td>';
echo '<td>'.($row['gender']==0?'男':'女').'</td>';
echo '<td>'.$row['birthdate'].'</td>';
echo '<td>'.$row['hobby'].'</td>';
switch($row['degree']){
case '1':$dg = "高中";break;
case '2':$dg = "大学";break;
case '3':$dg = "研究生";break;
case '4':$dg = "博士生";break;
}
echo '<td>'.$dg.'</td>';
echo '<td>'.$row['intro'].'</td>';
echo '<td align="center"><img src='.UserPhotoPath.$row['pic'].' width=60
height=80></td>';
echo '<td><a href="userEditForm.php?id='.$row['uid'].'">修改</a> |
<a href="userDelete.php?id='.$row['uid'].'" onClick="return confirm(\'确定要删除吗？
\');">删除</a></td>';
echo '</tr>';
}
echo '</table>';
$totalrows = mysql_num_rows($result);
echo "<table align='center'><tr><td>共有{$totalrows}名用户</td></tr></table>";
?>
</body>
</html>
<!-- userListPage.php 用于列出所有用户，增加了搜索功能和分页显示的功能。 -->
